#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QMainWindow>
#include <QWidget>
#include <QLabel>
#include <QActionGroup>
#include <QWorkspace>
#include <QTextEdit>
#include "child/glchildfactory.h"

QT_BEGIN_NAMESPACE
class QAction;
class QMenu;
class QMdiSubWindow;
class QSignalMapper;
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT
    
public:
    MainWindow(QWidget *parent = 0);
    ~MainWindow();

private slots:
    void newFile();
    void open();
    void save();
    void saveAs();
    void cut();
    void copy();
    void paste();
    void about();
    void updateIO();
    void updateViewMenu();
    void updateWindowMenu();

    void genFractal();

    void drawCSGNaively();

private:
    void createActions();
    void createMenus();
    void createToolBars();
    void createStatusBar();
    void createDockWidget();

    void createCSGActions();

    GLChildCSG *createGLChild();
    GLChild * activeGLChild();

    QWorkspace *workspace;
    QSignalMapper *windowMapper;

    QMenu *menuFile;
    QMenu *menuEdit;
    QMenu *menuWindow;
    QMenu *menuHelp;
    QMenu *menuView;
    QMenu *menuFractal;
    QMenu *menuCSG;

    QMenu *menuViewMaterial;
    QActionGroup *actMatGp;

    QToolBar *toolBarFile;
    QToolBar *toolBarEdit;
    QToolBar *toolBarView;
    QToolBar *toolBarFractal;
    QToolBar *toolBarCSG;

    QAction *actNew;
    QAction *actOpen;
    QAction *actSave;
    QAction *actExit;

    QAction *actViewReset;
    QAction *actViewLight;
    QAction *actViewMaterial[MATERIAL_END];

    QAction *actFractal;

    QAction *actCSGNaive;

    QAction *actClose;
    QAction *actCloseAll;
    QAction *actTile;
    QAction *actCascade;
    QAction *actNext;
    QAction *actPrevious;
    QAction *actSeparator;
    QAction *actAbout;
    QAction *actAboutQt;

    QLabel *labelRunStatus;

    QDockWidget *dockWidgetOutput;
    QTextEdit *editOutput;
};

#endif // MAINWINDOW_H
